package factories;

import org.json.JSONException;
import org.json.JSONObject;

import dataFormat.CalendarTextData;

public class CalendarTextDataFactory {
	public static CalendarTextData newByJsonObject(JSONObject jsonObj) {
		CalendarTextData calendarTextData = null;
		
		try {
			int day = jsonObj.getInt("day");
			String[] startTime = jsonObj.getString("startTime").split(":");
			int startHour = Integer.parseInt(startTime[0]);
			int startMinute = Integer.parseInt(startTime[1]);
			String[] overTime = jsonObj.getString("overTime").split(":");
			int overHour = Integer.parseInt(overTime[0]);
			int overMinute = Integer.parseInt(overTime[1]);
			int priority = jsonObj.getInt("priority");
			String title = jsonObj.getString("title");
			String ps = jsonObj.getString("ps");
			
			calendarTextData = new CalendarTextData(day, startHour, startMinute, overHour,
					overMinute, priority, title, ps);
		} catch (JSONException e) {
			e.printStackTrace();
		}
		return calendarTextData;
	}
}
